<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="taglibs.jsp" %>
<%-- <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> --%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${path}/static/bootstrap-3.3.7-dist/css/bootstrap.css"/>
<link rel="stylesheet" href="${path}/static/layui/css/layui.css" media="all">
</head>
<body>
	<form class="layui-form layui-form-pane" id="ajax_form"  method="post" onsubmit="return false">
	<div class="layui-form-item">
	    <label class="layui-form-label">ID</label>
	    <div class="layui-input-inline">
	      <input type="hidden" name="id" lay-verify="required" value="${student.id}" autocomplete="off" class="layui-input">
	  </div>
	 <div class="layui-form-item">
	    <label class="layui-form-label">分类</label>
	    <div class="layui-input-inline">
	      <input type="text" name="categoryId" autocomplete="off" placeholder="请输入标题" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">商品名称</label>
	    <div class="layui-input-inline">
	      <input type="text" name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  
	  <div class="layui-form-item">
	      <label class="layui-form-label">副标题</label>
	      <div class="layui-input-block">
	        <input type="text" name="subtitle" id="date1" autocomplete="off" class="layui-input">
	      </div>
	  </div>
	  <div class="layui-form-item">
	      <label class="layui-form-label">商品价格</label>
	      <div class="layui-input-block">
	          <input type="text" name="price"  class="layui-input"  >
	      </div>
	  </div>
	  <div class="layui-form-item">
	      <label class="layui-form-label">库存数量</label>
	      <div class="layui-input-block">
	          <input type="text" name="stock"  class="layui-input"  >
	      </div>
	  </div>
	  
	  <div class="layui-form-item">
	    <button class="layui-btn" onclick="submitForm()" value="添加">跳转式提交</button>
	  </div>
	</form>

	<script src="${path}/static/jquery-1.11.3.js"></script>
	<script src="${path}/static/mylayer.js"></script>
	<script src="${path}/static/util.js"></script>
	<script src="${path}/static/layui/layui.js"></script>
	<script>
		layui.use(['form', 'laydate','layer'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,laydate = layui.laydate;
		 
		 /*  laydate.render({
			  elem: '#birthdayId'
			  ,trigger: 'click'
		  }); */
		});
		
		/* 
		layer.confirm( function(index){
	    	  $.ajax({
	    		  url : "${path}/student/getUpdatePage.action",
	    		  data : {"id" : data.id},
	    		  dataType : "json",
	    		  type : "post",
	    		  success : function(jsonObj) {
	    			  if (jsonObj.code == util.SUCCESS) {
	    				  mylayer.successMsg(jsonObj.msg);
	    				  // 重新加载数据表格
	    				  table.reload("tableReload");
	    			  } else {
						  mylayer.errorMsg(jsonObj.msg);		    				  
	    			  }
	    		  }
	    	  });  */
		
		
		
		function submitForm() {
			$.ajax({
				url : "${path}/product/update.action",
				type : "post",
				dataType : "json",
				data : $("#ajax_form").serialize(),
				success : function(jsonObj) {
					console.log(jsonObj);
					if(jsonObj.code == util.SUCCESS) {
						mylayer.successMsg(jsonObj.msg);
						//当你在iframe页面关闭自身时
						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						setTimeout(function(){
							parent.layer.close(index); //再执行关闭 
							// 刷新父页面
							window.parent.location.reload();
						},1000);
					} else {
						mylayer.errorMsg(jsonObj.msg);
					}
					
				}
			});
		}
</script>
</body>
</html>